<?php

class Model_admin extends CI_Model {

    function __construct() {
        parent::__construct();
        $this->load->database();
        $this->load->helper('text');
    }

    function get_user($where = array()) {
        $this->db->select('user_id,nama_depan,nama_belakang,email,level,username,password');
        return $this->db->get_where('user', $where);
    }

    function get_user_id($where = array()) {
        $query = $this->fetch_user($where);
        if ($query->num_rows() == 1) {
            $row = $query->row();
            return $row->user_id;
        }
        return FALSE;
    }

    function fetch_user($where = array()) {
        $this->db->select('user_id');
        return $this->db->get_where('user', $where);
    }

    function is_highest_admin($str_id = '') {
        $sql = "select level from user where user.user_id = ?";
        $query = $this->db->query($sql, $str_id);

        if ($query->num_rows() == 1) {
            $row = $query->row();
            if ($row->level == '1') {
                return TRUE;
            } else {
                return FALSE;
            }
        } else {
            return FALSE;
        }
    }

}

?>
